﻿using System.Diagnostics;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Publishing;

namespace Eneta.Portal.Deployment
{
    public class EnetaProvisioningEngine : SPWebProvisioningProvider
    {
        public override void Provision(SPWebProvisioningProperties props)
        {
            Debug.Print("Started provisioning Eneta portal site definition");

            var web = props.Web;
            var lang = props.Web.Language;

            SPWebTemplateCollection webTemplates = web.Site.RootWeb.GetAvailableWebTemplates(lang);
            foreach (SPWebTemplate template in webTemplates)
            {
                Debug.Print(template.Name);
            }
            web.ApplyWebTemplate("EnetaPortal#0");
            web.Update();

            Debug.Print("Eneta portal is provisioned successfully");
        }
    }
}
